package com.lakeworks.common.enums;

import com.lakeworks.common.exception.response.ResponseException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;

import static com.lakeworks.common.enums.ResponseEnum.VALUE_NO_EXIST;
import static java.util.Arrays.stream;

@Getter
@AllArgsConstructor
public enum OprProductType {

    VERIFY("1", "核查中"),

    TOWASH("2", "待洗涤"),

    WASHING("3", "洗涤中"),

    WASHED("4", "已洗涤"),

    TOINSPECT("5", "待质检"),

    ATTACH("6", "配附件"),

    TOWRAP("7", "待包装"),

    WRAPPED("8", "已包装"),

    PLACED("9", "已上架"),

    TOPICK("10", "待拣货"),

    PICKED("11", "已拣货"),

    PACKED("12", "已装箱"),

    SHIPPED("13", "已出厂");

    private final String value;

    private final String name;

    private static final HashMap<String, OprProductType> map = new HashMap<>(32);

    static {
        stream(values()).forEach(oprProductType -> map.put(oprProductType.getValue(), oprProductType));
    }

    public static String getName(String value) {
        if (!map.containsKey(value))
            throw new ResponseException(VALUE_NO_EXIST);
        return map.get(value).getName();
    }

    public static OprProductType instance(String value) {
        if (!map.containsKey(value))
            throw new ResponseException(VALUE_NO_EXIST);
        return map.get(value);
    }

}
